package com.huaqiang.test.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaqiang.test.pojo.vo.DevicesVo;
import com.huaqiang.test.pojo.query.DevicesQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.huaqiang.test.pojo.entity.Devices;
import com.huaqiang.test.mapper.DevicesMapper;
import com.huaqiang.test.service.DevicesService;

import java.util.List;
/**
 * 设备表 服务实现类
 *
 * @author crelle
 * @since 2025-03-20 04:48:55
 */
@Service
public class DevicesServiceImpl extends ServiceImpl<DevicesMapper, Devices> implements DevicesService {

    @Autowired
    private DevicesMapper devicesMapper;

    /**
     * 增加Devices
     *
     * @param devices
     * @return
     */
    @Override
    public Devices create(Devices devices) {
        super.save(devices);
        return devices;
    }

    /**
     * 批量增加Devices
     *
     * @param devicess
     * @return
     */
    @Override
    public List<Devices> create(List<Devices> devicess) {
        super.saveBatch(devicess);
        return devicess;
    }

    /**
     * 根据id删除Devices
     *
     * @param id
     * @return
     */
    @Override
    public boolean deleteById(String id) {
        return super.removeById(id);
    }

    /**
     * 根据id批量删除Devices
     *
     * @param ids
     * @return
     */
    @Override
    public boolean deleteByIds(List<String> ids) {
        return super.removeBatchByIds(ids);
    }

    /**
     * 根据id修改Devices
     *
     * @param devices
     * @return
     */
    @Override
    public boolean update(Devices devices) {
        return super.updateById(devices);
    }

    /**
     * 根据id批量修改Devices
     *
     * @param devicess
     * @return
     */
    @Override
    public boolean updates(List<Devices> devicess) {
        return super.updateBatchById(devicess);
    }

    /**
     * 自动分页查询Devices，仅仅适用于单表查询
     *
     * @param page
     * @return
     */
    @Override
    public Page<Devices> pageByCondition(Page<Devices> page) {
        LambdaQueryWrapper<Devices> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (null != page && page.getRecords().size() != 0) {
            Devices devices = page.getRecords().get(0);
            lambdaQueryWrapper.like(null != devices.getId(), Devices::getId, devices.getId());
        }
        return super.page(page, lambdaQueryWrapper);
    }

    /**
     * 手动分页查询Devices，用于多表查询
     *
     * @param pageBean
     * @return
     */
    @Override
    public Page<DevicesVo> manualPage(Page<DevicesQuery> pageBean) {
        return null;
    }

    /**
     * 查询Devices详情
     *
     * @param id
     * @return
     */
    @Override
    public Devices queryById(String id) {
        return super.getById(id);
    }

    /**
     * 根据id批量查询Devices
     *
     * @param ids
     * @return
     */
    @Override
    public List<Devices> queryByIds(List<String> ids) {
        return super.listByIds(ids);
    }

    /**
     * 查询所有Devices
     *
     * @return
     */
    @Override
    public List<Devices> queryAll() {
        return super.list();
    }
}
